import sys
line = '911'
call={
    '1': (1, 1),
    '2': (1, 2),
    '3': (1, 3),
    '4': (2, 1),
    '5': (2, 2),
    '6': (2, 3),
    '7': (3, 1),
    '8': (3, 2),
    '9': (3, 3),
    '*': (4, 1),
    '0': (4, 2),
    '#': (4, 3),
     }
org = '5'
o_l = call.get(org)[0]
o_r = call.get(org)[1]
ll = 0
for d in line:
    t_l = call.get(d)[0]
    t_r = call.get(d)[1]
    o_l = call.get(d)[0]
    o_r = call.get(d)[1]
    ll += (abs(o_l - t_l) + abs(o_r - t_r))

print(ll)
